<?php

namespace app\index\controller\consulting;

use app\index\service\DesignateConsultingService;
use app\index\traits\SubscribeMessageTemplateTrait;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\index\model\UM as UM;
use app\index\service\RandomConsultingService;
use think\APP;
use think\Request as Request;

/**
 * Class DesignateConsulting
 * @package app\index\controller\consulting
 */
class DesignateConsulting
{
    use SubscribeMessageTemplateTrait;

    // 请求参数
    private Request $request;

    // service
    private DesignateConsultingService $service;

    public function __construct(Request $request, DesignateConsultingService $designateConsultingService)
    {
        $this->request = $request;
        $this->service = $designateConsultingService;
    }

    /**
     * 新增-找律师
     * @param UM $user
     * @return ApiResponse
     * @url /consulting/designate_consulting/save
     */
    public function save(UM $user): ApiResponse
    {
        $request = $this->request;

        $data = $this->service->add($user, $request->param());

        // 返回客户端订阅消息
        $data['subscribe_message_templates'] = $this->getConsultingSubscribeMessageTemplates();

        return ApiResponse::success($data);
    }

}
